package cn.ehanghai.htz.controller;

import cn.ehanghai.htz.client.TcpClient;
import cn.ehanghai.htz.common.constants.ReturnCode;
import cn.ehanghai.htz.thread.TcpClientReadAisThread;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author: xumf
 * @Date: 2019/7/11 16:52
 */
@RequestMapping("/socket")
@RestController
@CrossOrigin
public class SocketController {

    /**
     * 启动读取
     * @return
     */
    @RequestMapping("/open")
    public ReturnCode startSocket(){
//        TcpClient.socketTest();
        TcpClient.setReadFlag(true);
        new TcpClientReadAisThread().start();
        return ReturnCode.success();
    }

    /**
     * 关闭读取
     * @return
     */
    @RequestMapping("/close")
    public ReturnCode closeSocket(){
        TcpClient.setReadFlag(false);
        return ReturnCode.success();
    }
}
